#include "frameshadowjob.h"

#include <jobs/kdcstandardkprocessjob.h>
#include <KStandardDirs>

FrameShadowJob::FrameShadowJob( const QPixmap &aInput, QObject *aParent ) : KDCFrameJobInterface( aParent )
{
	aInput.save( pDir.name() + "/out.png", "png" );
	KDCStandardKProcessJob *job = new KDCStandardKProcessJob( this );
	job->setProgram( "convert" );
	job->setWorkingDirectory( pDir.name() );
	job->addArgument( "-page", "+4+4" );
	job->addArgument( "out.png" );
	job->addArgument( "-matte" );
	job->addArgument( "\\( +clone -background black -shadow 60x4+4+4 \\)" );
	job->addArgument( "+swap" );
	job->addArgument( "-background", "none" );
	job->addArgument( "-mosaic" );
	job->setOutputFile( "out.png" );
	job->workAsShell( true );
	addSubjob( job );
}

FrameShadowJob::~FrameShadowJob()
{

}

QPixmap FrameShadowJob::resultFrame() const
{
	return QPixmap( pDir.name() + "/out.png" );
}
